package leetcode

func generate(numRows int) [][]int {
	if numRows <= 0 {
		return nil
	}

	if numRows == 1 {
		return [][]int{{1}}
	}

	trangle := make([][]int, numRows)
	var i, j int

	trangle[0] = []int{1}
	for i = 1; i < numRows; i++ {
		trangle[i] = make([]int, i+1)
		trangle[i][0] = 1
		for j = 1; j < i; j++ {
			trangle[i][j] = trangle[i-1][j-1] + trangle[i-1][j]
		}
		trangle[i][j] = 1
	}
	return trangle
}
